package com.heima.wemedia.controller;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmNewsDto;
import com.heima.model.wemedia.dtos.WmNewsPageReqDto;
import com.heima.wemedia.service.WmNewsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author jack
 * @data 2024 9:47
 */
@RestController
@Slf4j
@RequestMapping("/api/v1/news")
public class WmNewsController {

    @Autowired
    private WmNewsService wmNewsService;

    /**
     * 查询文章列表
     *
     * @return
     */
    @PostMapping("list")
    public ResponseResult list(@RequestBody WmNewsPageReqDto reqDto) {
        return wmNewsService.queryByPageWithConditions(reqDto);
    }

    /**
     * 发布文章
     *
     * @return
     */
    @PostMapping("submit")
    public ResponseResult submit(@RequestBody WmNewsDto wmNewsDto){
        return wmNewsService.submit(wmNewsDto);
    }
}
